package com.kitty.web.controller;

import com.kitty.web.controller.BaseController;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.PRewardset;
import com.kitty.web.system.rewardset.service.IPRewardsetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 充值奖励Controller
 * 
 * @author soul
 * @date 2022-03-09
 */
@Controller
@RequestMapping("/system/rewardset")
public class PRewardsetController extends BaseController
{
    private String prefix = "system/rewardset";

    @Autowired
    private IPRewardsetService pRewardsetService;


    @GetMapping()
    public String rewardset()
    {
        return prefix + "/rewardset";
    }

    /**
     * 查询充值奖励列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PRewardset pRewardset)
    {
        startPage();
        List<PRewardset> list = pRewardsetService.selectPRewardsetList(pRewardset);
        return getDataTable(list);
    }


    /**
     * 新增充值奖励
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存充值奖励
     */

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PRewardset pRewardset)
    {
        return toAjax(pRewardsetService.insertPRewardset(pRewardset));
    }

    /**
     * 修改充值奖励
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PRewardset pRewardset = pRewardsetService.selectPRewardsetById(id);
        mmap.put("pRewardset", pRewardset);
        return prefix + "/edit";
    }

    /**
     * 修改保存充值奖励
     */

    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PRewardset pRewardset)
    {
        return toAjax(pRewardsetService.updatePRewardset(pRewardset));
    }

    /**
     * 删除充值奖励
     */

    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pRewardsetService.deletePRewardsetByIds(ids));
    }
}
